﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace cnFederal.Fa_Forms
{
    public partial class FaLinks : System.Web.UI.Page
    {
        List<CnfiLink> _links;
        public FaLinks()
        {
            CnfImages.Load();
            CnfiLinks.Load();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
          
            _links = CnfiLinks.GetAllFaLinks();
            InitializeTable();
            
        }


        private void InitializeTable()
        {
            if (_links != null && _links.Count != 0)
            {
                int teller = 0;
                TableRow tRow = new TableRow();
                for (int t = 0; t < _links.Count; t++)
                {
                    
                    if (teller % 4 == 0)
                    {
                        tRow = new TableRow();
                        tRow.ID = teller + "-Row" + t;
                    }
                    
                        TableCell tCell = new TableCell();
                        tCell.ID = teller + "_Cell";
                        tCell.Height = 60;
                        tCell.Width = 60;
                        tCell.VerticalAlign = VerticalAlign.Top;
                        tCell.BorderStyle = BorderStyle.None;
                        tCell.HorizontalAlign = HorizontalAlign.Center;
                        ImageButton imgbtn = new ImageButton();
                        imgbtn.Height = 40;
                        imgbtn.Width = 40;
                        imgbtn.ImageAlign = ImageAlign.Middle;
                        imgbtn.ImageUrl = _links[teller].ImageUrl;
                        imgbtn.PostBackUrl = _links[teller].LinkUrl;
                        tCell.Controls.Add(imgbtn);
                        
                       

                        HyperLink txtLink = new HyperLink();
                        txtLink.Text = _links[teller].Title;

                        txtLink.NavigateUrl = _links[teller].LinkUrl;
                        txtLink.Text = @"<br />" + _links[teller].Title;
                        txtLink.Target = "_new";
                        
                        tCell.Controls.Add(txtLink);
                        tRow.Controls.Add(tCell);
                        teller++;
                    
                    Table1.Controls.Add(tRow);
                    
                }
            }
        }




    }
}